<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

/*Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});*/

$api = app('Dingo\Api\Routing\Router');

// 登录验证
$api->version('v1',[
    'namespace' => 'App\Http\Controllers\Api\Admin',
    'middleware' =>[ 'serializer:array','bindings'],
],function ($api){
    $api->group([ 'prefix'=>'admin','middleware'=>'api.auth'],function ($api){
        //会员
        $api->get('members','MembersController@index');

        //分类
        $api->post('categories',"CategoriesController@store")->name('api.categories.store');
        $api->get('categories',"CategoriesController@index")->name('api.categories.index');
        $api->put('categories/{category}','CategoriesController@update')->name('api.categories.update');
        $api->delete('categories/{category}','CategoriesController@destory')->name('api.categories.destory');

        //商品
        $api->get('goods','GoodsController@index')->name('api.goods.index');
        $api->post('goods','GoodsController@store')->name('api.goods.store');
        $api->delete('goods/{good}','GoodsController@destory')->name('api.goods.destory');
        $api->put('goods/{good}','GoodsController@update')->name('api.goods.update');


        //竞拍商品
        $api->get('jinpais','JinpaisController@index')->name('api.jinpais.index');

        $api->put('jinpais/{jinpai}','JinpaisController@update')->name('api.jinpais.update');

        //添加轮播图
        $api->post('banners/store',"BannerController@store")->name('api.banner.store');
        $api->get('banners/list',"BannerController@list")->name('api.banner.list');
        $api->delete('banners/{banner}',"BannerController@destory")->name('api.banner.destory');
        $api->put('banners/{banner}',"BannerController@update")->name('api.banner.update');

        //后台管理员添加

        $api->put('admin/{adminUser}',"AdminuserController@update")->name('api.adminuser.update');
        $api->delete('admin/{adminUser}',"AdminuserController@destory")->name('api.adminuser.destory');
        $api->get('admin/list',"AdminuserController@list")->name('api.adminuser.list');

        //订单管理
        $api->get('order/{order?}',"OrderController@index");
        $api->delete('order/{order}',"OrderController@destory");
        $api->get('order/edit/{order}',"OrderController@edit");

        //晒单
        $api->get('saidans','SaidanController@index');
        $api->put('saidans/{saidan}','SaidanController@update');
        $api->delete('saidans/{saidan}','SaidanController@destory');

        //帮助
        $api->post('help/store','HelpController@store');
        $api->put('help/{help}','HelpController@update');
        $api->get('help/list','HelpController@list');
        $api->delete('help/{help}','HelpController@delete');

        //七牛云上传图片   配置文件要填写
        $api->post('imgages','ImagesController@store');
    });






});


  //后台
$api->version('v1',[
    'namespace' => 'App\Http\Controllers\Api\Admin',
    'middleware' =>[ 'serializer:array','bindings']
],function ($api){
    $api->group([
 /*      'middleware' => 'api.throttle',
        'limit' => 10000,
        'expires' => 1,*/
        'prefix'=>'admin'
    ],function ($api){
        //无需登录

        $api->post('login',"LoginController@login")->name('api.login');
        $api->post('logout',"LoginController@logout")->name('api.logout');
    });
});

//前台
$api->version('v1',[
    'namespace' => 'App\Http\Controllers\Api\Home',
    'middleware' =>[ 'serializer:array','bindings']
],function ($api){
    $api->group([
    ],function ($api){
        //无需登录
        //图形验证码
        $api->post('captchas','CaptchasController@store')->name('api.captchas.store');
        //验证
        $api->post('verificationCodes','VerificationCodesController@store')->name('api.verificationCodes.store');

        //注册
        $api->post('users','UsersController@store')->name('api.users.store');

        $api->get('goods/{type?}/{id?}','AuctionController@index');
        $api->get('/test','AuctionController@test');

        $api->get('users/{user}/collect','UsersController@collects');

        //晒单
//        $api->get('shaidan/{saidan?}','SaidanController@index');
        $api->post('shaidan/store','SaidanController@store');


    });
    //第三方登录
    $api->post('socials/{social_type}/authorizations','AuthorizationsController@socialStore')->name('api.socialas.authorizations.store');

    //登录
    $api->post('authorizations','AuthorizationsController@store')->name('api.authorizations.store');

    $api->put('authorizations/current','AuthorizationsController@update')->name('api.authorizations.update');

    $api->delete('authorizations/current','AuthorizationsController@destroy')->name('api.authorizations.destroy');


    //竞拍中的商品
    $api->get('jinpais','JinpaiController@index');

    // 用户收藏
    $api->get('users/{user}/collect','UsersController@collects');

    //晒单
    $api->get('saidan/{saidan?}','SaidanController@index');
    $api->post('saidan/store','SaidanController@store');

    //收货地址
    $api->post('address/store','UsersController@addressadd');
    $api->put('address/{address}','UsersController@addressupdate');
    $api->get('address/{user}','UsersController@addresslist');
    $api->delete('address/{address}','UsersController@addressdelete');

    //充值活动 用户登录添加充值活动表 状态为未开始参与活动
    $api->post('chong/store','ShouchongController@store');
    //参与充值活动后   该用户的充值记录中add-time添加时间
    $api->post('chong/star','ShouchongController@star');
    //该用户领币情况
    $api->get('chong','ShouchongController@index');
    //领取赠币
    $api->post('chong/getMoney','ShouchongController@getMoney');
    //帮助
    $api->get('help','SearchController@help');
    //轮播图
    $api->get('banner','SearchController@banner');
    //成交记录
    $api->get('chengjiao','SearchController@chengjiao');




});


